package com.fanrenqiji.modules.sys.dao;

import com.fanrenqiji.common.persistence.BaseDao;
import com.fanrenqiji.common.persistence.BaseDaoImpl;
import com.fanrenqiji.modules.sys.entity.BlockList;
import com.fanrenqiji.modules.sys.entity.Config;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

public interface BlockListDao extends BlockListDaoCustom,CrudRepository<BlockList, Long>{
	@Modifying
	@Query("update BlockList set delFlag='" + BlockList.DEL_FLAG_DELETE + "' where id = ?1 ")
	void deleteById(Long id);
	
	
	@Query("from Config where delFlag='" + Config.DEL_FLAG_NORMAL + "' and type = ?1")
	List<Config> findByConfigType(String type);
	
	@Query("from BlockList where delFlag='" + Config.DEL_FLAG_NORMAL + " ' and (mobile=?1 or idCard=?2)")
	BlockList findByMobileOrIdCard(String mobile, String idCard);
	
	
}

interface  BlockListDaoCustom extends BaseDao<BlockList>{}

@Repository
class BlockListDaoImpl extends BaseDaoImpl<BlockList> implements BlockListDaoCustom{
	
}
